<template>
  <a-modal
    title="工艺路线"
    width="80%"
    :visible="visible"
    :destroyOnClose="true"
    @ok="confirm"
    @cancel="cancel"
  >
    <a-select v-model="selVal" style="width: 100%" placeholder="请选择工艺路线" >
      <a-select-option
        v-for="(item,index) in workRouteList"
        :key="index"
        :value="item.id">{{ item.name }}</a-select-option>
    </a-select>
  </a-modal>
</template>

<script>
import { workRouteList } from '@/api/modular/main/workroute/workRouteManage'
import XEUtils from 'xe-utils'
export default {
  name: 'WorkRouteSel',
  data() {
    return {
      // 是否可见
      visible: false,
      selVal: '',
      // 工艺路线list
      workRouteList: []
    }
  },
  methods: {
    open() {
      this.visible = true
      this.getWorkRouteList()
    },

    getWorkRouteList() {
      workRouteList().then(res => {
        this.workRouteList = res.data || []
      })
    },

    confirm() {
      this.$emit('confirm', XEUtils.find(this.workRouteList, item => item.id === this.selVal))
      this.visible = false
    },
    cancel() {
      this.visible = false
    }
  }
}
</script>

<style scoped>

</style>
